package com.chat.mapper;

import com.chat.annotation.AutoFill;
import com.chat.dto.EmployeeCheckDTO;
import com.chat.entity.Employee;
import com.chat.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

//员工端
@Mapper
public interface EmployeeMapper {

    @Select("select * from chat_app.employee where username = #{username}")
    Employee getByUsername(String username);

    //新增用户
    @Insert("insert into employee (stuNumber, userImage, username, password, phone, sex," +
            " create_time, update_time, create_user, update_user,status)" +
            " values(#{stuNumber},#{userImage},#{username},#{password},#{phone},#{sex}," +
            "#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    @AutoFill(value = OperationType.INSERT)
    void insertEmployee(Employee employee);

    //注册校验
    @Select("select * from chat_app.employee where stuNumber = #{stuNumber} or username = #{username} or phone = #{phone}")
    List<Employee> getRegisterCheck(EmployeeCheckDTO employeeCheckDTO);
}
